<template>
  <form>
    <view class="area" v-for="(item,index) in address" v-bind:key="index">
      <view class="area-head">
        <label>{{item.name}}</label>
        <text>{{item.phone}}</text>
      </view>
      <view class="area-text">
        <text class="def" v-if="item.default == 1">默认</text>
        <text>{{item.procince}}</text>
        <text>{{item.city}}</text>
        <text>{{item.area}}</text>
        <text>{{item.detailed}}</text>
      </view>
      <navigator url="/pages/amend/amend" redirect>
        <view class="compile">编辑</view>
      </navigator>
      <view class="area-time">{{item.created_time}}</view>
    </view>
    <navigator url="/pages/addshipp/addshipp" redirect>
      <view class="newadd">添加新地址</view>
    </navigator>
  </form>
</template>

<script>
// import {request} from "../../request/index.js"
export default {
  data() {
    return {
      address: [
        // {
        //   address_id: 1, //地址名
        //   user_id: "猪哞哞", //用户名
        //   default: 1, //默认
        //   phone: "13491125063", //电话
        //   procince: "四川省", //省份
        //   city: "内江市", //城市
        //   area: "东兴区", //区域
        //   detailed: "东桐路705号内江师范学院", //详细
        //   status: 1, //状态
        //   created_time: "2020-03-14", //创建时间
        // },
        // {
        //   address_id: 1, //地址名
        //   user_id: "鸭嘎嘎", //用户名
        //   default: 0, //默认
        //   phone: "13491125063", //电话
        //   procince: "四川省", //省份
        //   city: "成都市", //城市
        //   area: "双流区", //区域
        //   detailed: "华府大道3段556号绿荫小区", //详细
        //   status: 1, //状态
        //   created_time: "2020-08-22", //创建时间
        // },
      ],
      list: [],
    };
  },
  methods: {
    
  },
  //   mounted:
  //     function (options) {
  //       request({url:"http://api_dev.wanxikeji.cn/api/userAddressList"})
  //       .then(result =>{
  //         this.setData({
  //           list: result.data.message
  //         })
  //       })
  //   },
  onLoad: function (options) {
    var that = this;
    if (uni.getStorageSync("token")) {
      let data = {};
      data.token = uni.getStorageSync("token");

      wx.request({
        url: "http://api_dev.wanxikeji.cn/api/userAddressList",
        // data: {},
        method: "POST", // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
        data: data,
        // header: {'Authorization':token}, // 设置请求的 header
        // success: (result) => {
        //   this.setData({
        //     list: result.data.message
        //   })
        // },
        success: function (res) {
          // success
          console.log(that)
          console.log(res.data.data);
          that.address = res.data.data
        },
        fail: function () {
          // fail
        },
        complete: function () {
          // complete
        },
      });
        //console.log(data)
    }
  },
};
</script>

<style lang="scss" scoped>
.area {
  font-size: 25rpx;
  background: rgba(255, 255, 255, 1);
  /* display: flex; */
  flex-direction: row;
  position: relative;
  border-bottom: 1px solid rgb(243, 241, 241);
  padding: 10rpx 30rpx;
}
.area-head {
  overflow: hidden;
}
.area-head label {
  font-size: 29rpx;
  padding: 5rpx 0;
}
.area-head text {
  padding: 0 10px;
  font-size: 23rpx;
  color: rgb(156, 156, 156);
}
.area-text {
  overflow: hidden;
  width: 80%;
  line-height: 20px;
}
.area-text text {
  padding: 0 1px;
}
.area-text .def {
  padding: 0 6px;
  background: rgba(250, 189, 189, 0.6);
  color: rgba(247, 65, 65, 0.8);
  margin: 5rpx 0;
  margin-right: 7px;
}
.compile {
  position: absolute;
  right: 2%;
  top: 30%;
  padding: 5px 15px;
  border-left: 1px rgb(156, 156, 156) solid;
  cursor: pointer;
  color: rgb(156, 156, 156);
}
.area-time {
  color: rgb(156, 156, 156);
  font-size: 23rpx;
}
.newadd {
  text-align: center;
  padding: 20px 0;
  color: #f60;
  font-size: 30rpx;
}
</style>